home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / findNewCurrentModelView.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.9 KB  |  111 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Sept 25 1997
  22. //  Author:         cdg
  23. //
  24. //  Description:
  25. //      This script looks for a visible model view to set to be the 
  26. //        current view.
  27. //
  28. //  Input Arguments:
  29. //      None.
  30. //
  31. //  Return Value:
  32. //      True if success.
  33. //
  34. //    Note:
  35. //        None.
  36. // 
  37. global proc int findNewCurrentModelView() {
  38.  
  39.     global string $gMainPane;
  40.  
  41.     string $mainPaneCtls[];
  42.     string $visPanels[];
  43.     string $panelName;
  44.     string $panelCtl, $edCtl;
  45.     string $modelEd;
  46.     int    $nArr;
  47.     int       $i;
  48.     int    $newViewFound = false;
  49.  
  50.     //
  51.     //  First try to find something in the main pane.
  52.     //
  53.     if ($gMainPane != "") {
  54.         $mainPaneCtls = `paneLayout -q -ca $gMainPane`;
  55.         $nArr = size($mainPaneCtls);
  56.         for ($i = 0; $i < $nArr; $i++) {
  57.             $panelName = `getPanel -containing $mainPaneCtls`;
  58.             if ("" != $panelName) {
  59.                 if ("modelPanel" == `getPanel -to $panelName`) {
  60.                     if (!`control -q -io $mainPaneCtls`) {
  61.                         $modelEd = `modelPanel -q -modelEditor $panelName`;
  62.                         if ("" != $modelEd) {
  63.                             modelEditor -e -activeView $modelEd;
  64.                             $newViewFound = true;
  65.                             break;
  66.                         }
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.     }
  72.  
  73.     //
  74.     //  Try to find any visible model panel
  75.     //
  76.     if (!$newViewFound) {
  77.         $visPanels = `getPanel -vis`;
  78.         $nArr = size($visPanels);
  79.         for ($i = 0; $i < $nArr; $i++) {
  80.             if ("modelPanel" == `getPanel -to $visPanels[$i]`) {
  81.                 $modelEd = `modelPanel -q -modelEditor $visPanels[$i]`;
  82.                 if ("" != $modelEd) {
  83.                     modelEditor -e -activeView $modelEd;
  84.                     $newViewFound = true;
  85.                     break;
  86.                 }                
  87.             }
  88.         }
  89.     }
  90.  
  91.     //
  92.     //  Try to find any visible model editor.
  93.     //
  94.     if (!$newViewFound) {
  95.         string $eds[] = `lsUI -editors`;
  96.         $nArr = size($eds);
  97.         for ($i = 0; $i < $nArr; $i++) {
  98.             if (`objectTypeUI -isType "modelEditor" $eds[$i]`) {
  99.                 $edCtl = `modelEditor -q -control $eds[$i]`;
  100.                 if ("" != $edCtl && "NONE" != $edCtl && !`control -q -io $edCtl`) {
  101.                     modelEditor -e -activeView $eds[$i];
  102.                     $newViewFound = true;
  103.                     break;
  104.                 }                
  105.             }
  106.         }
  107.     }
  108.  
  109.     return $newViewFound;
  110. }
  111.